// function compose(...args) {
//   return function (value) {
//     return args.reverse().reduce((acc, fn) => {
//       return fn(acc);
//     }, value);
//   };
// }

const compose =
  (...args) =>
  (value) =>
    args.reverse().reduce((acc, fn) => fn(acc), value);

const reverse = (array) => array.reverse();
const first = (array) => array[0];
const toUpper = (s) => s.toUpperCase();

const getLastElementToUpperFn = compose(toUpper, first, reverse);
console.log(getLastElementToUpperFn(["one", "two", "three"]));
